package com.zzt.textlib;

import java.net.URLEncoder;
import java.util.Base64;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

/**
 * @author: zeting
 * @date: 2022/11/29
 */
public class DDDDDD {

    public static void main(String[] args) throws Exception {
        Long timestamp = System.currentTimeMillis();
        String secret = "SECca7b4bf83ecf84c8c074853d2ec89026f677d080c16f94bf8cf65676ba04096e";

        String stringToSign = timestamp + "\n" + secret;
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
        byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
        String sign = null;
        sign = URLEncoder.encode(new String(Base64.getEncoder().encode(signData)), "UTF-8");
        System.out.println("签名>>"+sign);
    }
}
